﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using FluentNHibernate.Mapping;

namespace Barry.BarbeSystem.Models
{
    public class BarberCategory
    {
        [Key]
        public virtual int Id {  set; get; }

        /// <summary>
        /// 项目类别
        /// </summary>
        [Required(ErrorMessage = "请填写名称")]
        [MaxLength(20)]
        [Display(Name = "理发项目类别名称")]
        public virtual string Name { set; get; }

        /// <summary>
        /// 是否可用
        /// </summary>
        [Display(Name = "是否可用")]
        public virtual bool Enable { set; get; }


       public  virtual IList<BarberDetail> Details { protected set; get; } 
    }


    public class BarberCategoryMap:ClassMap<BarberCategory>
    {
        public BarberCategoryMap()
        {
            Id(i => i.Id);
            Map(i => i.Name).Not.Nullable().Length(20);
            Map(i => i.Enable).Not.Nullable().Default("1");
            HasMany<BarberDetail>(i => i.Details).Inverse().LazyLoad();
        }
    }
}